import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;

/*
 ID: ning yusui
 LANG: JAVA
 TASK: fact4
 */

public class fact4 {
    Scanner in;
    PrintWriter out;

    public fact4() throws IOException {
        in = new Scanner(new File(this.getClass().getName() + ".in"));
        out = new PrintWriter(new BufferedWriter(new FileWriter(this.getClass().getName() +
                ".out")));
    }

    private void work() {
        int n = in.nextInt();
        int r = 0;
        BigInteger fact = BigInteger.ONE;
        for (int i = 1; i <= n; i++) {
            fact = fact.multiply(BigInteger.valueOf(i));
        }
        while (n > 0) {
            n /= 5;
            r += n;
        }
        String factStr = fact.toString();
        char ch = factStr.charAt(factStr.length() - 1 - r);
        out.println(ch);
        out.flush();
        out.close();
    }


    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        new fact4().work();
        System.out.println(System.currentTimeMillis() - start + "ms");
    }
}
